// JavaScript Document

$(function(){
	var objWH=window.Tool.getObjTopLeft('.masker');
	var tbT=parseFloat(objWH.top)<0?0:objWH.top+"px";
	var tbL=parseFloat(objWH.left)<0?0:objWH.left+"px";
	var  isup = null;
	var nowDate = new Date();
	switch( window.lev){
		case "1":
			$("#lockDiv").css({'height':window.Tool.getPageSize()[1]}).show();
			$("#mianfenup").css({top:tbT,left:tbL,display:"block"});
		break;
		case "2":
			if( window.is7days == '1'){
				if($.cookie("useCookieDate") == null || $.cookie("useCookieDate") =='' ){
					$.cookie('useCookieDate',nowDate.format('yyyy/MM/dd HH:mm:ss'));
					isup = true;
				}else {
					var diffDays = nowDate.diff( new Date( $.cookie('useCookieDate')) );//(相差多少秒)
					if( diffDays  > 3600 ) isup = true;
				}
				if(isup){
					$("#lockDiv").css({'height':window.Tool.getPageSize()[1]}).show();
					$("#is7days").css({top:tbT,left:tbL,display:"block"});
				}
			}else{

				if($.cookie("useCookieDate") == null || $.cookie("useCookieDate") =='' ){
					$.cookie('useCookieDate',nowDate.format('yyyy/MM/dd HH:mm:ss'));
					isup = true;
				}else {
					var diffDays = nowDate.diffdays( new Date( $.cookie('useCookieDate')) );//(相差多少秒)
					if( diffDays  > 1 ) isup = true;
				}
								
				if(isup){
					$("#lockDiv").css({'height':window.Tool.getPageSize()[1]}).show();
					$("#vipup").css({top:tbT,left:tbL,display:"block"});
				}
			}
		break;
		default:
		break;
	}
	$(".upclose").live('click',(function(){
		$.cookie('useCookieDate',nowDate.format('yyyy/MM/dd HH:mm:ss'));
		$(".masker").hide();
		$("#lockDiv").hide();	$("#lockDiv").hide();
	}));
	$("#mianfenup a").live("click",function(){
		$(".masker").hide();
		$("#lockDiv").hide();	$("#lockDiv").hide();
	});
	$(".upbtn").live('click',(function(){
		$.cookie('useCookieDate',nowDate.format('yyyy/MM/dd HH:mm:ss'));
		$(".masker").hide();
		$("#lockDiv").hide(); $("#lockDiv").hide();
	}));
	$(".dpmb_item").live("mouseenter",function(){
		$(this).addClass("item_sec");
		$(this).find(".main_act").removeClass("hid");
	});
	$(".dpmb_item").mouseleave(function(){
		$(this).removeClass("item_sec");
		$(".main_act").addClass("hid");
	});

	$("#item_2 a").click(function(){
		$("#index_lunbo").attr('style','left:-1px;top:-1px;display:none').effect("Slide",{'mode':'show','direction':'right'});
	});
	$("#index_lunbo").mouseleave(function(){
		$(this).effect("Slide",{'mode':'hide','direction':'left'});
	});

	$("#item_3 a").click(function(){
		$("#index_xiangqing").attr('style','left:-1px;top:-1px;display:none').effect("Slide",{'mode':'show','direction':'right'});
	});
	$("#index_xiangqing").mouseleave(function(){
		$(this).effect("Slide",{'mode':'hide','direction':'left'});
	});

	$("#item_23 a[data]").click(function(){
		$("#index_tuiguang").attr('style','left:-278px;top:-1px;display:none').effect("Slide",{'mode':'show','direction':'right'});
	});
	$("#index_tuiguang").mouseleave(function(e){
		var e = e || window.event,target = e.target || e.srcElement;
		if( target.id == 'index_copyUrl750' || target.id == 'index_copyUrl950')return false;
		$(this).effect("Slide",{'mode':'hide','direction':'left'});
	});
	$("#index_copyUrl750").zclip({
		copy: function() {
			return $("#in_link750").val();
		},
		afterCopy: function() {
			$("#dialog-msg").html("<p style='font-size:12px;'><span class='ui-icon ui-icon-circle-check' style='float:left;margin:0 7px 30px 0;'></span>链接复制成功！<br>您可以复制地址发给您的QQ、旺旺好友，或发布到各大微博、社区、热门站点进行推广！ </p>");
			$("#dialog-msg").dialog({
				title: '代码复制成功',
				height: 180,
				width: 360,
				resizable: false,
				modal: true,
				buttons: {
					"返回": function() {
						$(this).dialog("close")
					}
				}
			})
		}
	});

	$("#index_copyUrl950").zclip({
		copy: function() {
			return $("#in_link950").val();
		},
		afterCopy: function() {
			$("#dialog-msg").html("<p style='font-size:12px'><span class='ui-icon ui-icon-circle-check' style='float:left;margin:0 7px 30px 0;'></span>链接复制成功！<br>您可以复制地址发给您的QQ、旺旺好友，或发布到各大微博、社区、热门站点进行推广！ </p>");
			$("#dialog-msg").dialog({
				title: '代码复制成功',
				height: 180,
				width: 360,
				resizable: false,
				modal: true,
				buttons: {
					"返回": function() {
						$(this).dialog("close")
					}
				}
			})
		}
	});
	
/** 智能关联推荐的[取消推荐] **/
	$("#index_gl_del").click(function(){
		$.ajax({
			url:"http://li.dpmb.net/guanlian/ajax.htm",
			data:{"act":"uninstall"},
			type:"post",
			cache: false,
			dataType:"json",		
			beforeSend:function(XMLHttpRequest){
				var msg = '<div style="line-height:22px"><br>已提交服务器端取消<br>请稍后查看操作记录!</div>';			
				$("#lockDiv").show();
				$("#waiting").html(msg).show();				
				window.clearTimeout(window.tid);
				window.tid = setTimeout( 
				function(){$("#lockDiv,#waiting").hide('slow');	}, 3000);	
			},
			success:function(data,textStatus){
				$("#lockDiv,#waiting").hide();
				if (data!=undefined) {
					if(data.msg == 'lower_level'){
						$("#dialog-msg").html("<p style='font-size:14px'><br><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 30px 20px;'></span>"+data.sub_msg+"</p>");
						$("#dialog-msg").dialog({title:'权限不足',height:200,width:400,position:'center',resizable: false,modal: true,buttons: {
							"返回": function() {parent.$( this ).dialog( "close" );},
							"立即升级": function() {
								window.open('http://fuwu.taobao.com/ser/detail.htm?service_id=11727&trace=gl_update_index');
							}
							}, close:function(){$("#dialog-msg").dialog( "destroy" );}						
						});
					}else{ 			
						$("#dialog-msg").html("<p style='font-size:14px'><br><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 30px 10px;'></span>"+data.msg+"</p>");
						$("#dialog-msg").dialog({title:'系统提醒',height:200,width:400,resizable: false,modal: true, 
							buttons: {"返回": function() {$( this ).dialog( "close" ) }}
						});	
					}		
				}		
			}
		});		
	});

	$("[id^='btn_img']").click(function(){
		var _self = $(this),id = _self.attr("id").substring(8);
		switch( id ){
			case '1':
				location.href = "http://li.dpmb.net/modules/jieri/setplan.htm"
				break;
			case '2':
				location.href = 'http://li.dpmb.net/modules/youli/setplan.htm';
				break;
			case '3':
				location.href = 'http://li.dpmb.net/modules/tejia/setplan.htm';
				break;
			case '4':
				location.href = 'http://li.dpmb.net/modules/fengqiang/setplan.htm';
				break;
			case '5':
				location.href = 'http://li.dpmb.net/modules/tuangou/setplan.htm';
				break;
			case '6':
				location.href = 'http://li.dpmb.net/modules/miaosha/setplan.htm';
				break;
			case '7':
				location.href = 'http://li.dpmb.net/modules/xinpin/setplan.htm';
				break;
			case '8':
				location.href = 'http://li.dpmb.net/modules/shuaimai/setplan.htm';
				break;
			case '9':
				location.href = 'http://li.dpmb.net/modules/zhendian/setplan.htm';
				break;
		}	
		
	});
	$("[id^='xqy_btn_img']").click(function(){
		var _self = $(this),id = _self.attr("id").substring(12);
		switch( id ){
			case '1':
				location.href = 'http://li.dpmb.net/muban/?type=jr';
				break;
			case '2':
				location.href = 'http://li.dpmb.net/muban/?type=li';
				break;
			case '3':
				location.href = 'http://li.dpmb.net/muban/?type=tj';
				break;
			case '4':
				location.href = 'http://li.dpmb.net/muban/?type=tg';
				break;
			case '5':
				location.href = 'http://li.dpmb.net/muban/?type=ms';
				break;
			case '6':
				location.href = 'http://li.dpmb.net/muban/?type=xp';
				break;
			case '7':
				location.href = 'http://li.dpmb.net/muban/?type=sm';
				break;
			case '8':
				location.href = 'http://li.dpmb.net/muban/';
				break;
		}
	});
	$("#Map4").mouseenter(function(){
		$(".play_content").find("img").attr( 'src','http://img01.taobaocdn.com/imgextra/i1/95723640/T2n7AeXbNaXXXXXXXX-95723640.jpg');
	}).mouseout(function(){
		$(".play_content").find("img").attr( 'src','http://img04.taobaocdn.com/imgextra/i4/95723640/T2pP7YXbtXXXXXXXXX-95723640.jpg');
	}).click(function(){
		$(".play_content").html('<embed width="980" height="499" allownetworking="internal" allowscriptaccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" src="http://cloud.video.taobao.com//play/u/144283918/p/1/e/1/t/1/10555034.swf">');
	});
 	$("#flash_wrap").smallslider();
});
